<?php
namespace Pay\Model;
use Think\Model;

class OrderModel extends Model {

    private $T;

    public function _initialize(){
        $this->T = M('Order');
    }

    //添加订单
    public function addOrder($order_sn, $buyer, $order_amount, $charge_to, $pay_method, $status, $description, $server_id = '', $game_id = ''){
        $data['sn'] = $order_sn;
        $data['buyer'] = $buyer;
        $data['amount'] = $order_amount;
        $data['charge_to'] = $charge_to;
        $data['pay_method'] = $pay_method;
        $data['status'] = $status;
        $data['description'] = $description;
        $data['server_id'] = $server_id ? $server_id : '';
        $data['game_id'] = $game_id ? $game_id : '';

        if( $this->T->create($data) ){
            $this->T->add();
            return true;
        }else{
            return false;
        }
    }

}